from apscheduler.schedulers.background import BackgroundScheduler
from views import GetIpView, CheckIpView


def run():
    schedule = BackgroundScheduler()
    get_ip_obj = GetIpView.GetIpHandler()
    check_ip_obj = CheckIpView.CheckIpHandler()

    # 定时检测redis里的代理是否有效，无效的就剔除
    # schedule.every(15).minutes.do(check_ip_obj.check())
    schedule.add_job(check_ip_obj.check(), )
    # 当数量ip少于200时，自动更新代理池
    schedule.every(20).minutes.do(get_ip_obj.check_ip_nums())


if __name__ == '__main__':
    run()
